package cc.zzone.util;

import jakarta.servlet.http.Cookie;

import java.util.ArrayList;
import java.util.List;

/**
 * Cookie 工具类
 *
 * @author jinzhengze
 * @since 2023年3月30日
 */
public final class CookieUtil {

    private CookieUtil() {
    }

    public static List<Cookie> parseCookie(String cookies) {
        List<Cookie> cookieList = new ArrayList<>();
        String[] params = cookies.split(";");
        for (String param : params) {
            String[] arr = param.split("=");
            if (arr.length != 2) continue;
            cookieList.add(new Cookie(arr[0].trim(), arr[1].trim()));
        }
        return cookieList;
    }
}
